<!DOCTYPE html>
<style>
	 body {
	   background:url("bg2.gif")  no-repeat center center;   /*加载背景图*/   /* 背景图不平铺 */
	   background-size:cover;  /* 让背景图基于容器大小伸缩 */
	   background-attachment:fixed;        /* 当内容高度大于图片高度时，背景图像的位置相对于viewport固定 */    //此条属性必须设置否则可能无效/
	   background-color:#CCCCCC;   /* 设置背景颜色，背景图加载过程中会显示背景色 */
	  font-family:YouYuan;
	 }
	 a{
		 color:white;
		  text-decoration:none;
	 }
	 a:hover{
		 color:pink;
		 transform:translatey(50px);
		 text-decoration:none;
	 }
	 input{
	 		 font-size:40px;
	 		 font-family:YouYuan;
	 		 background-color: whitesmoke;
	 }
	 button{
		    font-size:40px;
		 	font-family:YouYuan;
		    background-color: gainsboro;
				 
		 }
	 }
</style>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		
	</head>
	<body>
	<a href="index.html" style="font-family: YouYuan;font-size:40px;color: #FFFFFF;">返回主页</a>
	<div style="text-align:center ;font-size:40px;margin-top:300px;">
		<form action='' method='post'>
			<p align='center'>模糊查询：<input type='text' name='context'/><button type='sumbit'>查找</button></p>
			<table border='1' align='center'>
			<tr bgcolor="#DCDCDC">
				<th>考试班级</th>
				<th>考试科目</th>
				<th>考试时间</th>
				<th>考试地点</th>
				<th>监考老师</th>
			</tr>

<?php
	if(isset($_POST['context']) && $_POST['context']!=""){
		$text = $_POST['context'];
		echo "<h2 align='center'>关于\"".$text."\"查询结果如下:</h2>";
		try{
			$db =new pdo("mysql:host=localhost;dbname=db_database10;charset=utf8","root","");
		}
		catch(Exception $exc){
			echo $exc->getMessage();
		}
		$stmt = $db->prepare("select * from exam where class like ? or room like ? or course like ? or time like ? or teacher like ?");
		$stmt->execute(array("%$text%","%$text%","%$text%","%$text%","%$text%"));
		while($results= $stmt->fetch(PDO::FETCH_ASSOC)){
			echo "<tr><td>".$results['class']."</td>";
			echo "<td>".$results['course']."</td>";
			echo "<td>".$results['time']."</td>";
			echo "<td>".$results['room']."</td>";
			echo "<td>".$results['teacher']."</td>";
		}
		echo "</table>" ;
		echo "</form>";
		if($stmt->rowCount()==0)
			echo "<h3 align='center'>此次查询没有结果</h3>";
	}
?>
	</div>
	</body>
</html>